﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
//#JMJ Create_20241215

namespace IHateWorking.Model
{
    public class Converter_OverPara2Visible : IValueConverter
    {
        /// <summary>
        /// 根据变量值超过参数值，返回控件的显示/折叠状态
        /// </summary>
        /// <param name="value">变量值</param>
        /// <param name="targetType"></param>
        /// <param name="parameter">阈值，默认为0</param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter is null)
            { parameter = 0; }
            if (value is null)
            { return Binding.DoNothing; }

            if (System.Convert.ToDouble(value) > System.Convert.ToDouble(parameter))
            { return Visibility.Visible; }
            else
            { return Visibility.Collapsed; }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        { return Binding.DoNothing; }
    }
}
